home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
MACAPP
/
PRE_3
/
UPROGRES
/
SETLINEW.P
next >
Wrap
Text File
|
1990-08-20
|
2KB
|
92 lines
{
A Hairline drawing control object, for thin lines printed on a LaserWriter.
It is an interface for the PicComment SetLineWidth.
SetLineWidth v1.0 5-15-90 by Brian Arnold
Copyright (c) 1990 Carnegie Mellon University
All Rights Reserved.
Like there's anything worth copyrighting here.
To use this TLineDrawer, simply instantiate, call ILineDrawer and store the
object reference somewhere (in a global or field of an object, perhaps).
Call BeginThinLine( kLaserPixels ) when you want a hairline, EndThinLine when
through drawing, and call Free when deleting.
NEEDS: FailNIL and DisposIfHandle from MacApp. Add our own failure if you
don't have MacApp.
}
CONST
kSetLineWidth = 182; { PicComment for fractional width line drawing }
kLaserPixels = 4; { roughly 4 laserwriter pixels per monitor pixel }
TYPE
{ data type for fractional width line drawing:
v/h of WidthPt describes fraction of QuickDraw pen size to use for drawing.
}
WidthPt = Point;
WidthPtr = ^WidthPt;
WidthHandle = ^WidthPtr;
TLineDrawer = OBJECT( TObject )
fWidth: WidthHandle; { handle to pen size ratio }
fDrawingThin: BOOLEAN; { whether we're currently drawing thin }
PROCEDURE TLineDrawer.ILineDrawer;
{ initialize fWidth, fDrawingThin }
PROCEDURE TLineDrawer.BeginThinLine( pixels: INTEGER );
{ prep thin line drawing, pass kLaserPixels }
PROCEDURE TLineDrawer.EndThinLine;
{ cleanup thin line drawing }
PROCEDURE TLineDrawer.Free;
OVERRIDE;
{ free up fWidth }
END;
PROCEDURE TLineDrawer.ILineDrawer;
BEGIN
fWidth := WidthHandle( NewHandle( SizeOf( WidthPt ) ) );
(* caller must handle failure *)
FailNIL( fWidth );
fDrawingThin := FALSE;
END;
PROCEDURE TLineDrawer.BeginThinLine( pixels: INTEGER );
BEGIN
IF ( fDrawingThin = FALSE ) AND ( fWidth <> NIL ) THEN BEGIN
(* set h to pixels, v/h will be fraction of 1/72 *)
fWidth^^.h := pixels;
fWidth^^.v := 1;
PicComment( kSetLineWidth, SizeOf( widthPt ), Handle( fWidth ) );
fDrawingThin := TRUE;
END;
END;
PROCEDURE TLineDrawer.EndThinLine;
BEGIN
IF ( fDrawingThin = TRUE ) AND (fWidth <> NIL ) THEN BEGIN
(* flip h and v *)
fWidth^^.v := fWidth^^.h;
fWidth^^.h := 1;
PicComment( kSetLineWidth, SizeOf( widthPt ), Handle( fWidth ) );
fDrawingThin := FALSE;
END;
END;
PROCEDURE TLineDrawer.Free;
OVERRIDE;
BEGIN
DisposIfHandle( Handle( fWidth ) );
INHERITED Free;
END;